package com.example.wyemail.MySwing;

import com.example.wyemail.MainEmail;

import javax.swing.*;

public class TaskWorker extends SwingWorker<Void, Void> {
    private String softDirectory;
    private String accountDocument;
    private String mainDirectory;
    private String exportDirectory;

    public TaskWorker(String softDirectory,String accountDocument,String mainDirectory,String exportDirectory) {
        this.softDirectory = softDirectory;
        this.accountDocument = accountDocument;
        this.mainDirectory = mainDirectory;
        this.exportDirectory = exportDirectory;
    }

    @Override
    protected Void doInBackground() throws Exception {
        // 在后台执行的任务
        try {
            MainEmail mainEmail = new MainEmail();
            mainEmail.AutoStart(softDirectory,accountDocument,mainDirectory,exportDirectory);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }

    @Override
    protected void done() {
        // 在后台任务完成后，更新 UI
        JOptionPane.showMessageDialog(null, "程序已执行");
    }
}